home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / tests / linsert.test < prev    next >
Text File  |  1993-06-19  |  3KB  |  92 lines

  1. # Commands covered:  linsert
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # All rights reserved.
  9. #
  10. # Permission is hereby granted, without written agreement and without
  11. # license or royalty fees, to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose, provided that the
  13. # above copyright notice and the following two paragraphs appear in
  14. # all copies of this software.
  15. #
  16. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. #
  21. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26. #
  27. # $Header: /user6/ouster/tcl/tests/RCS/linsert.test,v 1.5 93/06/19 14:31:26 ouster Exp $ (Berkeley)
  28.  
  29. if {[string compare test [info procs test]] == 1} then {source defs}
  30.  
  31. test linsert-1.1 {linsert command} {
  32.     linsert {1 2 3 4 5} 0 a
  33. } {a 1 2 3 4 5}
  34. test linsert-1.2 {linsert command} {
  35.     linsert {1 2 3 4 5} 1 a
  36. } {1 a 2 3 4 5}
  37. test linsert-1.3 {linsert command} {
  38.     linsert {1 2 3 4 5} 2 a
  39. } {1 2 a 3 4 5}
  40. test linsert-1.4 {linsert command} {
  41.     linsert {1 2 3 4 5} 3 a
  42. } {1 2 3 a 4 5}
  43. test linsert-1.5 {linsert command} {
  44.     linsert {1 2 3 4 5} 4 a
  45. } {1 2 3 4 a 5}
  46. test linsert-1.6 {linsert command} {
  47.     linsert {1 2 3 4 5} 5 a
  48. } {1 2 3 4 5 a}
  49. test linsert-1.7 {linsert command} {
  50.     linsert {1 2 3 4 5} 2 one two \{three \$four
  51. } {1 2 one two \{three {$four} 3 4 5}
  52. test linsert-1.8 {linsert command} {
  53.     linsert {\{one \$two \{three \ four \ five} 2 a b c
  54. } {\{one \$two a b c \{three \ four \ five}
  55. test linsert-1.9 {linsert command} {
  56.     linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
  57. } {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
  58. test linsert-1.10 {linsert command} {
  59.     linsert {} 2 a b c
  60. } {a b c}
  61. test linsert-1.11 {linsert command} {
  62.     linsert {} 2 {}
  63. } {{}}
  64. test linsert-1.12 {linsert command} {
  65.     linsert {a b "c c" d e} 3 1
  66. } {a b "c c" 1 d e}
  67. test linsert-1.13 {linsert command} {
  68.     linsert { a b c d} 0 1 2
  69. } {1 2  a b c d}
  70. test linsert-1.14 {linsert command} {
  71.     linsert {a b c {d e f}} 4 1 2
  72. } {a b c {d e f} 1 2}
  73. test linsert-1.15 {linsert command} {
  74.     linsert {a b c \{\  abc} 4 q r
  75. } {a b c \{\  q r abc}
  76. test linsert-1.16 {linsert command} {
  77.     linsert {a b c \{ abc} 4 q r
  78. } {a b c \{ q r abc}
  79.  
  80. test linsert-2.1 {linsert errors} {
  81.     list [catch linsert msg] $msg
  82. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  83. test linsert-2.2 {linsert errors} {
  84.     list [catch {linsert a b} msg] $msg
  85. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  86. test linsert-2.3 {linsert errors} {
  87.     list [catch {linsert a 12x 2} msg] $msg
  88. } {1 {expected integer but got "12x"}}
  89. test linsert-2.4 {linsert errors} {
  90.     list [catch {linsert \{ 12 2} msg] $msg
  91. } {1 {unmatched open brace in list}}
  92.